VxMenu


Build a Menu given a MenuBar and a list of items

Builds a Menu, given a MenuBar and a list of items.

Syntax

VxMenu formDialog menuBar menuList defaultCB

Description

To create a MenuBar on a Form dialog, you must specify the Form dialog to place the MenuBar on, the widget name of the MenuBar, a list of Menu item widgets to place on the MenuBar, and a default callback (if no callbacks are specified for the Menu items). Menu item widgets are buttons; typically, when a button in a MenuBar is pressed its callback creates a Menu.

Options

formDialog
The widget name of the Form dialog.

menuBar
The widget name of the MenuBar.

menuList
The Menu list to build from.

defaultCB
The default callback to call if one is not set in the menuList.

Each item in menuList is a list in the format:

type name mnemonic accelerator accelerator_string callback state

where:

type
is one of the follwoing:
pd
A Pulldown Menu

hp
A HelpPulldown Menu

cs
A CascadeButton

bt
A PushButton

sp
A Separator

name
is the name of the button.

mnemonic
is the mnemonic.

accelerator
is the accelerator.

accelerator_string
is the accelerator string of the button.

callback
is the callback to associate with the button.

state
If the item is a toggle button, this sets the initial state.

Example

The following code produces a MenuBar containing two Menus.

set menuList {
{pd Fruits F}
        {bt Kumquat K "" ""  }
        {bt Apple   A "" ""  }
        {bt Grape   G "" ""  }
        {bt Banana  B "" ""  }
        {sp}
        {bt Mango   M "" ""  }

    {pd Vegetables V}
        {bt Leek    L "" "" ""                }
        {bt Onion   O "" "" ""                }
}

set menubar [VtMenuBar $form.menubar]
VxMenu $form $menubar $menuList defaultCB

This code produces the following:

Note

Use VxMenuGetButton to get the reference to a Menu item widget; for example:

VxMenuGetButton $dlog "New"

See also VxMenuGetButton.